# $Id: configure.ac 172 2008-01-28 15:21:16Z yann.regisgianas $

AC_INIT

# Look for OCAML in the path.
AC_PATH_TOOL(OCAML,ocaml,no)
if test "$OCAML" == no ; then
	AC_MSG_ERROR(Cannot find ocaml.)
fi

# Look for OCAMLC in the path.
AC_PATH_TOOL(OCAMLC,ocamlc,no)
if test "$OCAMLC" == no ; then
	AC_MSG_ERROR(Cannot find ocamlc.)
fi

# Determine the library path to find AlphaLib.
AC_ARG_VAR([ALPHALIBPATH], [Path of AlphaLib])

if test "$ALPHALIBPATH" == "false"; then
   ALPHALIBPATH=`$OCAMLC -where`
fi

AC_CHECK_FILE($ALPHALIBPATH/alphaLib.cmo,,AC_MSG_ERROR([Could not find AlphaLib]))
ln -sf $ALPHALIBPATH lib 

# We check the Ocaml version number
AC_MSG_CHECKING(ocaml version)
OCAMLVERSION=`$OCAML str.cma check-ocaml-version.ml`
$OCAML str.cma check-ocaml-version.ml --gt 3.10 && echo $OCAMLVERSION

# Look for Menhir.
AC_PATH_TOOL(MENHIR,menhir,false)
if test "$MENHIR" = false ; then
	AC_MSG_ERROR(Cannot find Menhir.)
fi

# Look for AlphaCaml.
AC_PATH_TOOL(ALPHACAML,alphaCaml,false)
if test "$ALPHACAML" = false ; then
	AC_MSG_ERROR(Cannot find AlphaCaml.)
fi

# Look for Ergo.
AC_PATH_TOOL(ERGO,ergo,false)
if test "$ERGO" = false ; then
	AC_MSG_ERROR(Cannot find Ergo.)
fi

# Look for Simplify.
AC_PATH_TOOL(SIMPLIFY,simplify,false)
if test "$SIMPLIFY" = false ; then
	AC_MSG_WARN(Cannot find Simplify, that's ok, it's optional.)
fi

# Substitute in the configuration module.
AC_SUBST(OCAML)
AC_SUBST(ERGO)
AC_SUBST(SIMPLIFY)
AC_OUTPUT(src/configuration.ml)

